# coding: utf-8
goods = []
while len(goods) < 5:
    s = input('请添加5件商品，这是第' + str(len(goods) + 1) + '件')
    goods.append(s)

for good in goods:
    print(good)
cart = []
while True:
    s = input('请输入要购买商品，输入q退出')
    if s == 'q':
        break
    else:
        if s in goods:
            cart.append(s)
        else:
            print('商品不存在')

print('您要购买的商品有：')
for good in cart:
    print(good)